package no.ntnu.fp.gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import net.miginfocom.swing.MigLayout;
import no.ntnu.fp.gui.guiElements.CalendarPanel;
import no.ntnu.fp.model.Message;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import java.awt.Color;

public class CommandCentre {

	private JFrame frame;
	private JTextField txtSearchField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CommandCentre window = new CommandCentre();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public CommandCentre() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		try {
			UIManager
					.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		frame = new JFrame();
		frame.setBounds(100, 100, 858, 478);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(
				new MigLayout("",
						"[][100px,grow 15][grow][150px:250px,grow 15]",
						"[][60px][grow][]"));

		JButton btnAddAppointment = new JButton("Add Appointment");
		frame.getContentPane().add(btnAddAppointment, "cell 1 1,grow");

		JPanel eventPanel = new EventPanel();
		frame.getContentPane().add(eventPanel, "cell 2 1,grow");

		JButton btnLogout = new JButton("Logg ut");
		frame.getContentPane().add(btnLogout, "flowy,cell 3 1,grow");

		final JPanel messageContainer = new JPanel();
		messageContainer.add(new MessagePanel(Message.example()));

		frame.getContentPane().add(messageContainer, "cell 1 2,grow");

		JPanel calendarPanel = new CalendarPanel();
		frame.getContentPane().add(calendarPanel, "cell 2 2,grow");

		JPanel employeesPanel = new EmployeeCalendarSelectPanel();
		frame.getContentPane().add(employeesPanel, "cell 3 2,grow");
		employeesPanel.setLayout(new MigLayout("", "[grow,center]",
				"[22px][60px]"));

		JLabel lblName = new JLabel("Bjarne \u00C5s");
		lblName.setForeground(Color.GRAY);
		lblName.setFont(new Font("Dialog", Font.BOLD, 13));
		frame.getContentPane().add(lblName, "cell 3 1,alignx right");
	}

}
